package com.yunfangdata.web.controller;


import com.yunfangdata.domain.SalaryDetail;
import com.yunfangdata.query.SalaryDetailQueryObject;
import com.yunfangdata.query.SalaryQueryObject;
import com.yunfangdata.service.ISalaryDetailService;
import com.yunfangdata.util.JsonResult;
import com.yunfangdata.util.PageResult;
import com.yunfangdata.util.PermissionName;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("salaryDetail")
public class SalaryDetailController {

    @Autowired
    private ISalaryDetailService salaryDetailService;


    @RequiresPermissions("salaryDetail:index")
    @PermissionName("工资明细首页")
    @RequestMapping("")
    public String index(SalaryDetailQueryObject qo) {

        return "salaryDetail/list";

    }


    @RequiresPermissions("salaryDetail:list")
    @PermissionName("工资明细列表")
    @RequestMapping("list")
    @ResponseBody
    public PageResult list(SalaryQueryObject qo) {

        return salaryDetailService.query(qo);

    }





    @RequiresPermissions("salaryDetail:update")
    @PermissionName("工资明细表更新")
    @RequestMapping("update")
    @ResponseBody
    public JsonResult update(SalaryDetail salaryDetail) {
        JsonResult js = new JsonResult();
        try {
            salaryDetailService.update(salaryDetail);
        } catch (Exception e) {
            e.printStackTrace();
            js = new JsonResult("工资明细表更新失败");
        }

        return js;
    }

}
